<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-easyui-1.5.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.5.4.2/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.5.4.2/jquery.easyui.min.js"></script>
<script type="text/javascript"src="js/common.js"/></script>
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5.4.2/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5.4.2/themes/black/easyui.css"/>
</head>

<body>
	<script type="text/javascript">
		$(function() {
			$("#pro_btn_show").linkbutton({
				onClick : function() {
					$("#win").window("open");
				}
			});
			
			$("#pro_btn_close").linkbutton({
				onClick : function() {
					$("#win").window("close");
				}
			});
			
			$("#pro_btn_shuaxing").linkbutton({onClick:function(){
				$('#dg').datagrid({pageNumber:1, url:'get_all_pros_page'});
				//重新加载数据
				$('#cc').combobox('clear');
				$('#dd').searchbox('clear');
				$('#dg').datagrid('reload');		
				}});
		
		
		
			$('#lzh-win-pro-row').linkbutton({onClick:function(){
			$("#gggg").form({
				onSubmit:function(){
					
				},
			success:function(v){
				var ppp=JSON.parse(v);
				$('#dg').datagrid('loadData',ppp);
				$('#txt-pronid3').textbox("clear");
				$('#txt-pronid3').textbox("clear");
				$('#txt-proname3').textbox("clear");
				$('#txt-proInfoSta3').textbox("clear");
				$('#txt-proprice3').textbox("clear");
				$('#txt-prouit3').textbox("clear");
				$("#search_pro").window("close");
			
				
			}
			}).submit();
				
			}});
			
			
			
				
			$('#pro-append-row').linkbutton({onClick:function(){
				$("#ff").form({
					onSubmit:function(){
						return $("#ff").form("validate");
					},
					success:function(v){
						$.messager.alert('提示','提交成功');
						$('#txt-proname1').textbox("clear");
						$('#txt-classif1').textbox("clear");
						$('#txt-proInfoSta1').textbox("clear");
						$('#txt-proprice1').textbox("clear");
						$('#txt-prouit1').textbox("clear");
						$('#txt-procost1').textbox("clear");
						$('#txt-prosup1').textbox("clear");
						$('#add_pro').window('close');
						$('#dg').datagrid('reload');
					}
				}).submit();
			}});
			
			$('#pro_btn_del').linkbutton({onClick:function(){
				var biaoge=$("#dg");
				var rows=biaoge.datagrid("getSelections");
				if(rows!=""){
				$.messager.confirm('确认','您确认要删除记录吗？',function(r){
					if(r){
						$.messager.alert('提示','删除成功');
						var myids=new Array();
						for(var i = rows.length - 1; i >= 0; i --){
							myids[i]=rows[i].productId;
							var index = biaoge.datagrid("getRowIndex", rows[i]);
							biaoge.datagrid("deleteRow", index);
						}
						$.post('deletpro',{myids:myids});
					}
				})
				}else{
					$.messager.alert('警告','请选择行');
				}
			}});
			
			$('#pro_btn_upt').linkbutton({onClick:function(){
				var biaoge=$("#dg");
				var rows=biaoge.datagrid("getSelections");
				
				if(rows!=""){
				$('#upt_pro').window('open');
				var get = $("#dg").datagrid("getSelected");
				$("#txt-pronid").textbox('setText',get.productId);
				$("#txt-proname2").textbox('setText',get.productName);
				$("#txt-proInfoSta2").textbox('setText',get.proInfoSta);
				$("#txt-proprice2").textbox('setText',get.proPrice);
				$("#txt-prouit2").textbox('setText',get.unitId);
				$("#txt-procost2").textbox('setText',get.proInfoCost);
				$("#txt-classif2").textbox('setText',get.classifyName);
				$('#fff').form('load',get);
			}
				else{
					$.messager.alert('警告','请选择行');
				}}
				
			});
			
			$('#pro-upt').linkbutton({onClick:function(){
				$("#fff").form({
					onSubmit:function(){
						return $("#fff").form("validate");
					},
					success:function(v){
						$.messager.alert('提示','提交成功');
						$('#txt-proname2').textbox("clear");
						$('#txt-classif2').textbox("clear");
						$('#txt-proInfoSta2').textbox("clear");
						$('#txt-proprice2').textbox("clear");
						$('#txt-prouit2').textbox("clear");
						$('#txt-procost2').textbox("clear");
						$('#txt-prosup2').textbox("clear");
						$('#upt_pro').window('close');
						$('#dg').datagrid('reload');
					}
				}).submit();
			}});
	
		})
		
		
		
		
		
		function fun() {
			obj = document.getElementsByName("test");
			check_vala = [];
			check_valb=[];
			for (var bb=0;bb<obj.length;bb++) {
				if (obj[bb].checked){
					check_vala.push(obj[bb].value);
					
				}else{
					check_valb.push(obj[bb].value);
				}
			
			}

		
			var shus=["w","e","t","r","y","u","m","o","d","f"];
			var cols = $("#dg").datagrid('getColumnFields');

			for(var i=0;i<check_vala.length;i++){
				for(var j=0;j<shus.length;j++){
					//这个地方
					if(check_vala[i]==document.getElementById(""+shus[j]+"").innerText){
						
						$('#dg').datagrid('showColumn', ''+cols[j+1]+'');
					}
				}
			} 
				
				for(var i=0;i<check_valb.length;i++){
					for(var j=0;j<shus.length;j++){
						//这个地方
						if(check_valb[i]==document.getElementById(""+shus[j]+"").innerText){
							$('#dg').datagrid('hideColumn', ''+cols[j+1]+'');
						}
					}
			}
		
		}
		
		function haha(){
		/* 	$("#search_pro").window("clear"); */
			$("#search_pro").window("open");
		}
		
	</script>
	<style type="text/css">
   #win {
	font-size: 20px;
}
</style>
	<table id="dg" class="easyui-datagrid" 
	data-options="fit:true,toolbar:'#tb',url:'get_all_pros_page',method:'get',title:'产品信息',border:false,fitColumns:true,pagination:true">
		<thead>
			<tr>
				<th  data-options="field:'aaa',width:1,checkbox:true"></th>
				<th id="w" data-options="field:'productId',width:35" >编号</th>
				<th id="e" data-options="field:'productName',width:120">产品名称</th>
				<th id="t" data-options="field:'proPrice',width:60,formatter:function(value,row,index){
				if(value){
				return '￥'+value}}">产品价格</th>	
		     	<th id="r" data-options="field:'classifyName',width:100,hidden:'true',formatter:function(value,row,index){
				if(value){
				return value;}
				else{
				return'/';}}">产品分类</th>
				<th id="y" data-options="field:'inveProNumb',width:100">产品库存数量</th>
				<th id="u" data-options="field:'proInfoSta',width:100">产品型号</th>
				<th id="m" data-options="field:'unitId',width:60">产品单位</th>
				<th id="o" data-options="field:'empno7',width:200,hidden:'true'">产品供应商</th>
				
				<th id="d" data-options="field:'proInfoCost',width:60,hidden:'true',formatter:function(value,row,index){
				if(value){
				return '￥'+value}}">产品成本</th>
				<th id="f" data-options="field:'proSta',width:80,formatter:function(value,row,index){
				if(value==0){
				return '正常';
				}else{
				return '停售';}}">产品状态</th>

			</tr>
		</thead>

	</table>



	<div id="tb">
		<a id="pro_btn_add" href="#" class="easyui-linkbutton"
			data-options="iconCls:'icon-add',plain:true" onclick="$('#add_pro').window('open')">添加</a> 
	    <a id="pro_btn_del" href="#" class="easyui-linkbutton"
			data-options="iconCls:'icon-remove',plain:true">删除</a> 
		<a id="pro_btn_upt" href="#" class="easyui-linkbutton"
			data-options="iconCls:'icon-edit',plain:true">修改</a>
	
		<div style="margin-left: 200px; margin-top: -25px">
			<input id="cc" name="aaaa" class="easyui-combobox"  data-options="prompt:'产品分类',panelHeight: 'auto',
			method:'get',url:'get_all_classify',valueField:'classifyId',textField:'classifyName'" />
		<div>
		
				<div style="margin-left: 700px; margin-top: -25px">
					<a id="pro_btn_show" class="easyui-linkbutton" data-options="iconCls:'icon-manage',plain:true">字段显示</a>
					 	
				</div>
				
				<div style="margin-left: 330px; margin-top: -25px">
					<input id="dd" class="easyui-searchbox" data-options="width:200, prompt:'关键字',menu:'#mm',
					searcher:function(value,name){
					$('#dg').datagrid({pageNumber:1, url: 'get_all_pros_page_where'});
					$('#dg').datagrid('reload',{key:value,key1:$('#cc').combobox('getValue')});	
		
					}">
					<div id="mm">
						<div data-options="name:'item1',iconCls:'icon-search',selected:true">普通查询</div>
						<div id="gg" data-options="name:'item3',iconCls:'icon-mac'" onclick="haha()">高级查询</div>
						
					</div>
					<div style="margin-left: 200px; margin-top: -25px"><a id="pro_btn_shuaxing" class="easyui-linkbutton" data-options="iconCls:'icon-shuaxing',plain:true"></a></div>
				</div>
				
	</div>


			<div id="win" class="easyui-window" title="产品字段选择"
				style="width: 400px; height: 400px"
				data-options="iconCls:'icon-save',modal:true,closed:true">
				
				
				编号: <input id="pp" type="checkbox" name="test" value="编号" checked="false"> 
				    <br /> 
				    产品名称: <input id="pp" type="checkbox" name="test" value="产品名称" checked="false"> 
				    <br />
				    产品价格: <input id="pp" type="checkbox" name="test" value="产品价格" checked="false"> 
				    <br />
				产品分类: <input id="pp" type="checkbox" name="test" value="产品分类"> 
				    <br /> 
				产品库存数量: <input id="pp" type="checkbox" name="test" value="产品库存数量" checked="false"> 
					<br /> 
				 产品型号: <input id="pp" type="checkbox" name="test" value="产品型号" checked="false"> 
			        <br /> 
				产品单位: <input id="pp" type="checkbox" name="test" value="产品单位" checked="false">
				    <br /> 
			         产品供应商: <input id="pp" type="checkbox" name="test" value="产品供应商"> 
			        <br /> 
				    产品成本: <input id="pp" type="checkbox" name="test" value="产品成本" > 
					<br />
				产品状态: <input id="pp" type="checkbox" name="test" value="产品状态" checked="false"> 
				    <br /> 
				    
				<input id="pro_btn_close" type='button' value='提交' onclick="fun()" style="width:100px;margin-left:140px;margin-top:30px"/>
				<br/>
	
				<p style="font-size:8px">注：为了界面的美化简洁，建议不要选择过多或过少字段</p>
			</div>
			
			
			<div id="search_pro" class="easyui-window" title="高级查询" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,closed:true,iconCls:'icon-mac'"style="width:400px;height:400px;padding:5px;">
				<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',href:'toLookup'" style="padding:10px;">
			</div>
				
				<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="lzh-win-pro-row" class="easyui-linkbutton" data-options="iconCls:'icon-gaojichaxun', plain:true" href="javascript:void(0)">查找</a>
			
			</div>
			
			</div>
			</div>
			
			<div id="add_pro" class="easyui-window" title="增加产品信息" data-options="collapsible:false,minimizab:false,model:true,closed:true,iconCls:'icon-sava'"style="width:400px;height:450px;padding:5px;">
			<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',href:'toadd_product'" style="padding:10px;"></div>
			
		   <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="pro-append-row" class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" href="javascript:void(0)">添加</a>
				<a class="easyui-linkbutton"  data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)" onclick="$('#add_pro').window('close');">关闭</a>
			</div>
			
			
			
			</div></div>
			
			
				<div id="upt_pro" class="easyui-window" title="修改产品信息" data-options="collapsible:false,minimizab:false,model:true,closed:true,iconCls:'icon-sava'"style="width:400px;height:450px;padding:5px;">
			<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',href:'toupt_product'" style="padding:10px;"></div>
			
		   <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a id="pro-upt" class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" href="javascript:void(0)">修改</a>
				<a class="easyui-linkbutton"  data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)" onclick="$('#upt_pro').window('close');">关闭</a>
			</div>
			</div></div>
</body>
</html>